Skip to content

feat(integrations): Gate user info behind data_collection config#6876

Draft
ericapisani wants to merge 5 commits into
py-2583-starlite-and-litestarfrom
py-2583-misc
Draft

feat(integrations): Gate user info behind data_collection config#6876
ericapisani wants to merge 5 commits into
py-2583-starlite-and-litestarfrom
py-2583-misc

Conversation

@ericapisani

@ericapisani ericapisani commented Jul 23, 2026

Copy link
Copy Markdown
Member

This is a clean up pass from areas that I missed initially.

Refs PY-2583
Fixes #6746

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

PY-2583

@ericapisani
ericapisani changed the base branch from master to py-2583-starlite-and-litestar July 23, 2026 20:52
The request event processor reads aws_event["identity"] at the top level,
but the payloads used by the user info tests nested it under requestContext,
so no user was attached and the assertions failed in CI.
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

97062 passed | ⏭️ 6410 skipped | Total: 103472 | Pass Rate: 93.81% | Execution Time: 352m 15s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +1202
Passed Tests 📈 +1132
Failed Tests
Skipped Tests 📈 +70

All tests are passing successfully.

❌ Patch coverage is 76.60%. Project has 2525 uncovered lines.
❌ Project coverage is 89.66%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
sentry_sdk/integrations/aws_lambda.py 21.43% ⚠️ 11 Missing and 2 partials
sentry_sdk/integrations/quart.py 100.00% ⚠️ 3 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    89.67%    89.66%    -0.01%
==========================================
  Files          193       193         —
  Lines        24321     24425      +104
  Branches      8572      8672      +100
==========================================
+ Hits         21809     21900       +91
- Misses        2512      2525       +13
- Partials      1397      1405        +8

Generated by Codecov Action

Comment on lines +441 to +456
if has_data_collection_enabled(client_options):
if client_options["data_collection"]["user_info"]:
user_info = sentry_event.setdefault("user", {})

identity = aws_event.get("identity")
if identity is None:
identity = {}

id = identity.get("userArn")
if id is not None:
user_info.setdefault("id", id)

ip = identity.get("sourceIp")
if ip is not None:
user_info.setdefault("ip_address", ip)
elif should_send_default_pii():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWS Lambda body handling skipped when data_collection is enabled

When has_data_collection_enabled is true, the elif should_send_default_pii() branch is skipped, so request body is neither collected nor redacted.

Evidence
  • has_data_collection_enabled returns true when data_collection is configured in _experiments.
  • Entering the new if has_data_collection_enabled branch at line 441 skips the elif should_send_default_pii() branch at line 456.
  • Body collection (request["data"] = aws_event.get("body", "")) and redaction (AnnotatedValue.removed_because_raw_data()) live exclusively inside the skipped elif/else branches.
  • data_collection.py line 178 documents that bodies are collected regardless of PII settings by default.
  • All new data_collection test payloads use "body": null, so this regression is not exercised.

Identified by Warden · code-review · GGF-TPP

Comment on lines +430 to +432
"identity": {
"sourceIp": "213.47.147.207",
"userArn": "42"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWS Lambda user-info tests use non-standard event structure

The test payload changed from standard requestContext.identity to a top-level identity field that doesn't match real AWS API Gateway events, causing tests to verify behavior with a fictional event structure instead of production reality.

Evidence
  • sentry_sdk/integrations/aws_lambda.py _make_request_event_processor reads user identity via aws_event.get("identity") directly.
  • Real AWS API Gateway proxy events nest identity under requestContext (e.g., test_request_data_with_send_default_pii_false and test_request_data_with_data_collection_allowlist in the same file both use "requestContext": {"identity": {...}}).
  • The changed test and the new USER_INFO_PAYLOAD place identity at the top level, which matches the current code but does not exist in real AWS events, so the assertions pass in tests while the extraction may fail in production.

Identified by Warden · code-review · RCQ-XUC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support redacting/removing user data based on the data collection configuration

1 participant